package com.kfm.test;

import org.junit.Test;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

public class Encoder {

    @Test
    public void encode(){
        try {
            String str = "123456";
            System.out.println(URLEncoder.encode(str, "utf-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void decode(){
        String code = "%E5%BC%A0%E4%B8%89";
        try {
            System.out.println(URLDecoder.decode(code, "utf-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
}
